/**
 * 
 */
package com.mc.data;

import java.util.Base64;

/**
 * @author w.weizhen
 *
 */
public class StringBase64 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		try {
//			final Base64.Decoder decoder = Base64.getDecoder();
//			final Base64.Encoder encoder = Base64.getEncoder();
//			final String text = "字串文字";
//			final byte[] textByte = text.getBytes("UTF-8");
//			//编码
//			final String encodedText = encoder.encodeToString(textByte);
//			System.out.println(encodedText);
//			//解码
//			System.out.println(new String(decoder.decode(encodedText), "UTF-8"));
			
			
			final Base64.Decoder decoder = Base64.getDecoder();
			final Base64.Encoder encoder = Base64.getEncoder();
			final String text = "字串文字";
			final byte[] textByte = text.getBytes("UTF-8");
			//编码
			final String encodedText = encoder.encodeToString(textByte);
			System.out.println(encodedText);
			//解码
			System.out.println(new String(decoder.decode(encodedText), "UTF-8"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
